<template>
  <div class="max-box">
    <!-- 头部搜索、操作 -->
    <div class="header-box">
      <div class="header-left">
        <span>无人机</span>
      </div>
    </div>
    <!-- 内容区 -->
    <div class="content-box">
      <div class="drone-detail">
        <div class="one-msg" v-for="item in codeList">
          <div>
            <span>异常类型：</span>
            <span>{{ item.title }}</span>
          </div>
          <div class="num-box">
            <span>数量：</span>
            <span class="one-detail">{{ item.value }} </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { droneDetail } from "@/api/drone.js";
export default {
  data() {
    return {
      codeList: [
        {
          prop: "COVER",
          value: "",
          title: "遮挡",
        },
        {
          prop: "HOT_SPOTS",
          value: "",
          title: "点状热斑",
        },
        {
          prop: "HOT_X_BANDS",
          value: "",
          title: "横条状热斑",
        },
        {
          prop: "HOT_BANDS",
          value: "",
          title: "竖条状热斑",
        },
        {
          prop: "ALL_HOT_BANDS",
          value: "",
          title: "全红热斑",
        },
        {
          prop: "GUANO",
          value: "",
          title: "鸟粪",
        },
        {
          prop: "THICK_DUST",
          value: "",
          title: "厚积尘",
        },
      ],
    };
  },
  methods: {
    getDroneDetail() {
      let parseData;
      droneDetail().then((res) => {
        if (typeof res.data == "string") {
          parseData = JSON.parse(res.data);
          //   abnormalCounts
          this.codeList.forEach((item) => {
            parseData.abnormalCounts.forEach((item2) => {
              if (item.prop == item2.type) {
                item.value = item2.count;
              }
            });
          });
        }
        console.log(parseData);
      });
    },
  },
  mounted() {
    this.getDroneDetail();
  },
};
</script>
<style lang="less" scoped>
.max-box {
  width: 100%;
  padding-top: 16px;
  padding-right: 20px;
  box-sizing: border-box;
  display: flex;
  height: 100%;
  flex-direction: column;
  .header-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    // padding-right: 20px;
    margin-bottom: 16px;
    font-size: 16px;
    .header-left {
      span {
        font-size: 18px;
        color: #252b3a;
      }
      i {
        font-size: 20px;
      }
    }
  }
  .content-box {
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    flex-grow: 1;
    .drone-detail {
      height: 100%;
      overflow-y: auto;
      display: grid;
      padding: 16px;
      box-sizing: border-box;
      grid-template-columns: repeat(3, 1fr); /* 三列等宽 */
      grid-auto-rows: 80px; /* 自动调整行高度 */
      grid-gap: 20px; /* 列间距和行间距，可根据需要调整 */
      .one-msg {
        font-size: 12px;
        color: #00000073;
        .one-detail {
          color: #515561;
        }
        .num-box {
          margin-top: 10px;
        }
      }
    }
  }
}
</style>